<template>
	<view class="wrap">
		<view class="header">
			<view class="main">
				<image :src="shopInfo.logo" mode="aspectFill" class="logo"></image>
				<view class="info">
					<view class="name">{{shopInfo.shopName}}</view>
					<view class="address">
						<text class="iconfont icon-coordinates"></text>{{shopInfo.address}}
					</view>
					<view class="address">
						<text class="iconfont icon-dianhua"></text>{{shopInfo.bossPhone}}
					</view>
				</view>
			</view>
			<view class="description">{{shopInfo.description}}</view>
			<view class="balance">
				<div class="left">
					<div class="amount-item">店铺余额: <text>{{shopInfo.balance || 0}}元</text></div>
					<div class="amount-item">店铺积分: <text>{{shopInfo.points || 0}}</text></div>
				</div>
				<div class="center"><text>提现</text></div>
				<button type="default" @click="toEditShop">修改</button>
			</view>
		</view>
		<view class="list">
			<navigator url="/pages/shopManage/shopManage" class="cell">
				<text class="title">订单管理</text>
				<text class="iconfont icon-xiangyou"></text>
			</navigator>
			<navigator url="/pages/goodsManage/goodsManage" class="cell" v-if="shopInfo.serviceType == 1">
				<text class="title" >商品管理</text>
				<text class="iconfont icon-xiangyou"></text>
			</navigator>
			<navigator url="/pages/serviceOrderManage/serviceOrderManage" class="cell" v-else>
				<text class="title">服务管理</text>
				<text class="iconfont icon-xiangyou"></text>
			</navigator>
		</view>
	</view>
</template>

<script>
	import {
		utils
	} from '@/utils'
	import {
		Shop
	} from '@/apis'

	export default {
		data() {
			return {
				shopInfo: {}
			}
		},
		methods: {
			toEditShop() {
				utils.routerTo('/pages/createShop/createShop')
			}
		},
		mounted() {
			getShopInfo.call(this)
		}
	}

	function getShopInfo() {
		const userInfo = uni.getStorageSync("userInfo");
		utils.wxLoading()
		Shop.getUserShopDetail({
			data: {
				query: {
					id: userInfo.id
				}
			}
		}).then(res => {
			console.log("获取店铺信息成功")
			console.log(res)
			this.shopInfo = res.data.body
		}).finally(() => uni.hideLoading())

	}
</script>

<style lang="scss">
	page {
		background-color: #EFEFEF;
	}

	.wrap {
		.header {
			box-sizing: border-box;
			padding: 20rpx;
			background-color: #FF4A4A;

			.main {
				display: flex;

				.logo {
					width: 136rpx;
					height: 136rpx;
					border-radius: 10rpx;
					background-color: #C0C0C0;
					flex-shrink: 0;
				}

				.info {
					flex: 1;
					box-sizing: border-box;
					padding-left: 20rpx;

					.name {
						font-size: 36rpx;
					}

					.address {
						display: flex;
						align-items: center;
						color: #FFFFFF;
						font-size: 26rpx;

						text {
							padding-right: 10rpx;
							font-size: 13rpx;
						}
					}
				}

				.points {
					flex-shrink: 0;
					color: #FFF;
					font-size: 28rpx;
					display: flex;
					align-items: center;
				}
			}

			.description {
				color: #bbb;
				font-size: 24rpx;
				line-height: 1.5;
				padding: 10rpx;
				box-sizing: border-box;
			}

			.balance {
				display: flex;

				.left {
					font-size: 24rpx;
					color: #FFF;
					font-weight: normal;

					text {
						color: #333;
						display: inline-block;
						padding-left: 10rpx;
					}
				}

				.center {
					flex: 1;
					box-sizing: border-box;
					padding-left: 40rpx;

					text {
						display: block;
						color: #007AFF;
						text-decoration: underline;
					}
				}

				button {
					width: 160rpx;
					height: 60rpx;
					line-height: 50rpx;
					color: #E81010;
					line-height: 60rpx;
					font-size: 28rpx;

				}
			}

			.search {
				height: 88rpx;
				display: flex;
				align-items: center;
				border-radius: 10rpx;
				background-color: #FFFFFF;
				box-shadow: 0 4rpx 4rpx 0 rgba(0, 0, 0, 0.24);
				box-sizing: border-box;
				padding: 0 15rpx;

				input {
					flex: 1;
					font-size: 28rpx;
				}
			}
		}

		.list {
			margin-top: 20rpx;
		}

		.cell {
			box-sizing: border-box;
			padding: 0 20rpx;
			display: flex;
			height: 96rpx;
			background-color: #FFFFFF;
			font-size: 28rpx;
			align-items: center;
			margin-top: 2rpx;

			.title {
				flex: 1;
				padding-left: 10rpx;
			}

			.iconfont {
				color: #666;
			}

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>
